package com.vzoom.logdesensitization.autoconfig;

import com.vzoom.logdesensitization.AtStringTemplate;
import com.vzoom.logdesensitization.config.DesensitizationConfig;
import com.vzoom.logdesensitization.config.DesensitizationStrategyHolder;
import com.vzoom.logdesensitization.jackson.JsonDesensitizationStringSerializer;
import com.vzoom.logdesensitization.jackson.JsonStrDesensitizationStringSerializer;
import com.vzoom.logdesensitization.jackson.XmlStrDesensitizationStringSerializer;
import com.vzoom.logdesensitization.strategyimpl.*;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(DesensitizationConfig.class)
@Import(CustomSqlSessionFactory.class)
public class LogDesensitizationAutoConfiguration {

    @Bean
    public DesensitizationStrategyHolder desensitizationStrategyHolder() {
        return new DesensitizationStrategyHolder();
    }

    @Bean
    public AtStringTemplate atStringTemplate() {
        return new AtStringTemplate();
    }

    //Serializer start

    @Bean
    public JsonDesensitizationStringSerializer desensitizationStringSerializer() {
        return new JsonDesensitizationStringSerializer();
    }

    @Bean
    public JsonStrDesensitizationStringSerializer jsonStrDesensitizationStringSerializer() {
        return new JsonStrDesensitizationStringSerializer();
    }

    @Bean
    public XmlStrDesensitizationStringSerializer xmlStrDesensitizationStringSerializer() {
        return new XmlStrDesensitizationStringSerializer();
    }

    //从这里开始都是策略

    @Bean
    public AddressDesensitizationStrategy addressDesensitizationStrategy() {
        return new AddressDesensitizationStrategy();
    }

    @Bean
    public BankcardDesensitizationStrategy bankcardDesensitizationStrategy() {
        return new BankcardDesensitizationStrategy();
    }

    @Bean
    public BirthdayDesensitizationStrategy birthdayDesensitizationStrategy() {
        return new BirthdayDesensitizationStrategy();
    }

    @Bean
    public CompanyDesensitizationStrategy companyDesensitizationStrategy() {
        return new CompanyDesensitizationStrategy();
    }

    @Bean
    public EmailDesensitizationStrategy emailDesensitizationStrategy() {
        return new EmailDesensitizationStrategy();
    }

    @Bean
    public EmptyDesensitizationStrategy emptyDesensitizationStrategy() {
        return new EmptyDesensitizationStrategy();
    }

    @Bean
    public IdCardDesensitizationStrategy idCardDesensitizationStrategy() {
        return new IdCardDesensitizationStrategy();
    }

    @Bean
    public JsonDesensitizationStrategy jsonDesensitizationStrategy() {
        return new JsonDesensitizationStrategy();
    }

    @Bean
    public JsonStrDesensitizationStrategy jsonStrDesensitizationStrategy() {
        return new JsonStrDesensitizationStrategy();
    }

    @Bean
    public NameDesensitizationStrategy nameDesensitizationStrategy() {
        return new NameDesensitizationStrategy();
    }

    @Bean
    public NsrsbhDesensitizationStrategy nsrsbhDesensitizationStrategy() {
        return new NsrsbhDesensitizationStrategy();
    }

    @Bean
    public PassportDesensitizationStrategy passportDesensitizationStrategy() {
        return new PassportDesensitizationStrategy();
    }

    @Bean
    public PhoneNumberDesensitizationStrategy phoneNumberDesensitizationStrategy() {
        return new PhoneNumberDesensitizationStrategy();
    }

    @Bean
    public TelephoneNumberDesensitizationStrategy telephoneNumberDesensitizationStrategy() {
        return new TelephoneNumberDesensitizationStrategy();
    }

    @Bean
    public UserCodeDesensitizationStrategy userCodeDesensitizationStrategy() {
        return new UserCodeDesensitizationStrategy();
    }

    @Bean
    public XmlStrDesensitizationStrategy xmlStrDesensitizationStrategy() {
        return new XmlStrDesensitizationStrategy();
    }

}
